package com.antis.olsl.magic.adapter;

import android.graphics.Color;

import com.antis.olsl.magic.R;
import com.antis.olsl.magic.response.GetProductEfficiencyListResp;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.module.LoadMoreModule;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public class ProductListAdapter extends BaseQuickAdapter<GetProductEfficiencyListResp.ContentBean, BaseViewHolder> implements LoadMoreModule {
    public ProductListAdapter(int layoutResId, @Nullable List<GetProductEfficiencyListResp.ContentBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, GetProductEfficiencyListResp.ContentBean bean) {
        baseViewHolder.setText(R.id.text_product_code, bean.productCode);
        baseViewHolder.setText(R.id.text_product_name, bean.productName);
        baseViewHolder.setText(R.id.text_store_num, bean.storeNum);
        int profitGrade = bean.profitGrade;
        String grade;
        String gradeColor;
        // 1.高毛利 2.低毛利 3.一般毛利 4.负毛利
        switch (profitGrade) {
            case 1:
                grade = "高毛利";
                gradeColor = "#363e4b";
                break;
            case 2:
                grade = "低毛利";
                gradeColor = "#363e4b";
                break;
            case 3:
                grade = "一般毛利";
                gradeColor = "#363e4b";
                break;
            case 4:
                grade = "负毛利";
                gradeColor = "#f3504f";
                break;
            default:
                grade = "一般毛利";
                gradeColor = "#363e4b";
                break;
        }
        baseViewHolder.setText(R.id.text_profit_grade, grade);
        baseViewHolder.setTextColor(R.id.text_profit_grade, Color.parseColor(gradeColor));
    }
}
